function getIncomePay(list, month) {
    let income = 0
    let payment = 0
    list.forEach(item => {
        if ((new Date(item.timeleave).getMonth() + 1) === month) {
            income += item.income
            payment += item.payment
        }
    })
    return { income, payment }
}

function fun(list, month) {
    let rst = []
    while (month) {
        rst.push(getIncomePay(list, month))
        month--
    }
    return rst
}